<?php

require_once ("../Money.class.php");
require_once ("../MoneyOps.class.php");
require_once ("../MoneyExceptions.php");

class MoneyTestCase extends PHPUnit_Framework_TestCase
{
	private static $n12p0EUR, $n2p8EUR, $n14p8EUR, $n2p5US;

	public static function setUpBeforeClass() {
		MoneyTestCase::$n12p0EUR=MoneyFactory::getDefaultFactory()->createMoney(12, 0,"EUR");
		MoneyTestCase::$n2p8EUR=MoneyFactory::getDefaultFactory()->createMoney(2, 8,"EUR");
		MoneyTestCase::$n14p8EUR=MoneyFactory::getDefaultFactory()->createMoney(14, 8,"EUR");
		MoneyTestCase::$n2p5US = MoneyFactory::getDefaultFactory()->createMoney(2, 5, "US");
	}

	public function testAdd() {
		$this->assertTrue(
			MoneyOps::add(MoneyTestCase::$n12p0EUR, MoneyTestCase::$n2p8EUR)
			->equals(MoneyTestCase::$n14p8EUR)
			);
	}

	public function testSub() {
		$this->assertTrue(
			MoneyOps::sub(MoneyTestCase::$n14p8EUR, MoneyTestCase::$n2p8EUR)
			->equals(MoneyTestCase::$n12p0EUR)
		);
	}

	public function testCurrencyNotEqual() {
		$this->assertTrue(MoneyTestCase::$n2p5US->getCurrency() !== MoneyTestCase::$n12p0EUR->getCurrency());
	}
}
?>